﻿using System;
using NUnit.Framework;

namespace StringCalculator.Test
{
    [TestFixture]
    public class StringCalculatorTest
    {
        [Test]
        public void WhenEmptyInputThenReturnZero()
        {
            var result = StringCalculator.AddNumber("");
            Assert.AreEqual(0, result);
        }
        [Test]
        public void WhenAddingOneNumberReturnNumber()
        {
            var result = StringCalculator.AddNumber("1");
            Assert.AreEqual(1, result);
        }
        [TestCase ("1,2",3)]
        [TestCase ("1,2,3",6)]
        public void WhenAddingNumbersWithCommaReturnSum(string input, int expectedResult)
        {
            var actualResult = StringCalculator.AddNumber(input);
            Assert.AreEqual(expectedResult, actualResult);
        }
        [TestCase("1\n2",3)]
        public void WhenAddingNumbersWithSplitNewLineReturnSum(string input, int expectedResult)
        {
            var actualResult = StringCalculator.AddNumber(input);
            Assert.AreEqual(expectedResult, actualResult);
        }
        [Test]
        public void WhenInvalidStringReturnException()
        {
            Assert.Throws<ArgumentException>
                (
                    delegate { StringCalculator.AddNumber("1\n"); }
                );
        }
        [Test]
        public void WhenUserDefineDelimiterThenAddDelimiterAndReturnSum()
        {
            var actualResult = StringCalculator.AddNumber("//;1;2;3");
            Assert.AreEqual(6, actualResult);
        }
    }
}
